package com.lvkerry.orderfood.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;

/**
 * @author Kerry
 */

@Entity
@Table(name = "t_user")
public class UserEntity {
    private Long userId;
    private String username;
    private String password;
    /**
     * 用户类型,
     * ADMIN-管理员
     * USER-一般用户
     * BOSS-老板
     */
    private String userRole;
    private String name;
    private Long addTime;
    private Integer sex;
    private Long birthday;
    private String avatarUrl;
    private Integer isDeleted = 0;
    private String phoneNumber;


    @JsonManagedReference
    private UserDeskEntity userDeskEntity;

    @Id
    @Column(name = "user_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "username", length = 40, nullable = false, unique = true)
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }


    @Basic
    @Column(name = "password", length = 100, nullable = false)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "user_role", length = 16, nullable = false)
    public String getUserRole() {
        return userRole;
    }

    public void setUserRole(String userRole) {
        this.userRole = userRole;
    }

    @Basic
    @Column(name = "name", length = 200)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "add_time")
    public Long getAddTime() {
        return addTime;
    }

    public void setAddTime(Long addTime) {
        this.addTime = addTime;
    }

    @Basic
    @Column(name = "sex", length = 4)
    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    @Basic
    @Column(name = "birthday")
    public Long getBirthday() {
        return birthday;
    }

    public void setBirthday(Long birthday) {
        this.birthday = birthday;
    }

    @Basic
    @Column(name = "avatar_url", length = 300)
    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    @Basic
    @Column(name = "is_deleted", length = 4)
    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }


    @Basic
    @Column(name = "phone_number", length = 20, unique = true)
    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }



    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    public UserDeskEntity getUserDeskEntity() {
        return userDeskEntity;
    }

    public void setUserDeskEntity(UserDeskEntity userDeskEntity) {
        this.userDeskEntity = userDeskEntity;
    }

    @Override
    public String toString() {
        return "UserEntity{" +
                "userId=" + userId +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", userRole='" + userRole + '\'' +
                ", name='" + name + '\'' +
                ", addTime=" + addTime +
                ", sex=" + sex +
                ", birthday=" + birthday +
                ", avatarUrl='" + avatarUrl + '\'' +
                ", isDeleted=" + isDeleted +
                ", phoneNumber='" + phoneNumber + '\'' +
                ", userDeskEntity=" + userDeskEntity +
                '}';
    }
}
